home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr47 / asmlib40.zip / INPUT.DOC < prev    next >
Text File  |  1995-03-28  |  34KB  |  965 lines

  1.  
  2. ********************************  INPUT  ************************************
  3.  
  4. ASMLIB Input subroutines (C) Copyright 1991 - 1995 Douglas Herr
  5. all rights reserved
  6.  
  7. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  8.  
  9. A$EDIT:      editor module used by TEdit and GEdit.
  10.              Must be called by GEdit or TEdit
  11. Source:      a$edit.asm (getkey.asm, isdigit.asm, toupper.asm, tolower.asm)
  12.  
  13.              TEdit and GEdit edit a string on a single row of the screen
  14.              (without word wrap).  Strings longer than the column width of
  15.              the screen are scrolled left or right as required.  A public
  16.              byte in A$EDIT's data area, EWIDTH, establishes the effective
  17.              screen width limit.  EWIDTH is a not-to-exceed limit; if the
  18.              actual screen width is less than EWIDTH, EWIDTH is ignored
  19.              and the actual screen width is used instead.  ASMLIB's default
  20.              EWIDTH is 132.
  21.  
  22.              A$EDIT commands for both TEdit and GEdit are:
  23.  
  24.              Ctrl+left arrow = word left
  25.              Ctrl+right arrow = word right
  26.              Ctrl+end = clear to end of string
  27.              Home = go to start of string
  28.              End = go to end of string
  29.  
  30.  
  31.              Option bits, passed to GEdit or TEdit in register AL, are:
  32.  
  33.              Option 1 = upper case input
  34.              Option 2 = lower case input
  35.              Option 1 OR 2 = digits only input
  36.              Option 4 = exit when any non-editing extended key is pressed
  37.                         (example: F-keys, Alt+key; see TEdit)
  38.  
  39. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  40.  
  41. CLEARKEY:    clears the keyboard's 'type-ahead' buffer
  42.              Uses BIOS functions to remove all keys in the buffer.
  43. Source:      clearkey.asm (kifwait.asm, getkey.asm)
  44.  
  45. Call with:   no parameters
  46. Returns:     nothing
  47. Uses:        nothing
  48. Supports:    standard and enhanced keyboards
  49. Example:     call   clearkey
  50.  
  51.  
  52.  
  53. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  54.  
  55. GEDIT:       string editor for graphics modes
  56.              See also TEdit for text modes, A$EDIT for general information
  57. Source:      gedit.asm (a$edit.asm, gprint.asm, a$graph.asm, gcursor.asm,
  58.                         strspace.asm, heap.asm)
  59.  
  60. Call with:   DS:[SI] pointing to string buffer; may include a default string
  61.              DS:[DX] pointing to x- & y-coordinates
  62.              assumes DS:@data
  63.              CX = byte size of buffer
  64.              AL = option bits (see A$EDIT)
  65.              You must initialize the near heap before calling GEdit.
  66.              GEdit only works with DrawMode 1 or -1 (see DrawMode in
  67.              GRAPHICS.DOC).  GEdit forces drawmode to 1 or -1 and restores
  68.              the previous drawmode on exit.
  69. Returns:     AX = last key pressed (see getkey for key codes)
  70.              CX = new string length
  71. Uses:        AX, CX, flags
  72. Supports:    all ASMLIB graphics modes
  73. Example:
  74.  
  75. .data
  76. x       dw 8                      ; x-coordinate (pixels from left edge)
  77. y       dw 100                    ; y-coordinate (pixels from top of screen)
  78. extrn   ewidth:byte               ; byte in A$EDIT used to limit columns
  79.                                   ; displayed
  80. .code
  81.         .
  82.         .
  83.         .
  84.         mov   ax,@data
  85.         mov   ds,ax
  86.         assume  ds:@data
  87.         mov   ewidth,40           ; there's stuff on the right side of
  88.                                   ; the screen that should be left alone
  89.  
  90.         lea   si,string_buffer    ; near address of string buffer
  91.         mov   cx,len_buffer       ; byte length of buffer for the string
  92.         mov   al,0                ; nothing tricky
  93.         lea   dx,x                ; point to x & y coordinates
  94.                                   ; see GPrint for explanation of x and y
  95.         call  gedit
  96.  
  97.  
  98.  
  99. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  100.  
  101. GETKEY:      returns next key pressed
  102. Source:      getkey.asm (kbdtype.asm)
  103.  
  104. Call with:   no parameters
  105. Returns:     AL = ASCII key code
  106.              AH = 0 if normal key
  107.              AH = 1 if extended key code (such as function keys)
  108. Uses:        AX
  109.              Uses BIOS functions; supports enhanced keyboard if present
  110. Supports:    standard and enhanced keyboards
  111. Example:     call  getkey
  112.              shr   ah,1            ; a function key?
  113.              jc    function_key    ; jump if so
  114.  
  115.  
  116. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  117.  
  118. GETMARKED:   returns pointer to string marked by MARKFILE
  119. Source:      getmarkd.asm (strrchr.asm, strlen.asm)
  120.  
  121. Call with:   ES = segment address of filename list marked by MARKFILE
  122.              AX = filename index number (first marked file index = 0)
  123. Returns:     if AX = valid marked file index, ES:[BX] points to full filename
  124.                                               CX = length of filename
  125.              If GetMarked is called with AX = -1, the filename at the
  126.              MarkFile cursor is returned at ES:[BX] whether it was marked
  127.              or not.
  128.              If AX too big, CF = 1
  129. Uses:        ES, BX, CX
  130. Example:     see MARKFILE
  131.  
  132.  
  133. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  134.  
  135. GPICKF:      pick a file from a list of filenames
  136.              GPickF pops a window on the screen and displays filenames
  137.              matching an input filespec mask.  One filename may be selected
  138.              with cursor keys or with hotkeys.  When Esc, Enter or ^C is
  139.              pressed, GPickF restores the screen and returns the selected
  140.              filename to the calling program.
  141.              Unused memory must be released by STARTUP (see STARTUP.ASM or
  142.              TINY.ASM).  Also requires near heap (see MEMINIT).
  143.              See also MenuOption.
  144. Source:      gpickf.asm (filelist.asm, $gpick.asm, a$menu.asm, $graph.asm)
  145.  
  146. Call with:   DS:[SI] pointing to filespec mask
  147.              BX = initial selection (0 = first filename)
  148.              CX = file attribute mask
  149.              DS:[DX] pointing to upper left corner of menu box
  150.              assumes DS:DGROUP
  151. Returns:     AX = last key pressed
  152.              ES:[BX] points to filename selected
  153.              CX = maximum length of filename
  154. Uses:        AX, BX, CX, ES
  155. Supports:    all ASMLIB graphics modes
  156. Example:     see PICKF
  157.  
  158. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  159.  
  160. GPICKSTR:    pick a string from a list of ASCIIZ strings
  161. Source:      gpickstr.asm ($gpick.asm, $strlist.asm, a$menu.asm, $graph.asm)
  162.  
  163. Call with:   DS:[SI] pointing to list of ASCIIZ strings
  164.              BX = initial cursor position
  165.              DS:[DX] pointing to (x,y) coordinates of upper left corner
  166.                of selection box
  167.  
  168.              GPickStr pops a window on the screen and displays the list
  169.              of strings.  One string may be selected with cursor keys
  170.              or with hotkeys.  When Esc, Enter or ^C is pressed, GPickStr
  171.              restores the screen and returns a string index number.
  172.              Unused memory must be released by STARTUP (see STARTUP.ASM and
  173.              TINY.ASM), and the near heap must be initialized (see MEMINIT).
  174.              See also MenuOption.  Maximum number of choices: 255
  175.  
  176. Returns:     AX = last key pressed
  177.              BX = string number selected (first string = 0)
  178. Uses:        AX, BX
  179. Supports:    all ASMLIB graphics modes
  180. Example:     see PICKSTR
  181.  
  182.  
  183.  
  184. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  185.  
  186. ISALPHA:     determines if a keycode returned by GetKey is a letter from
  187.              A-Z or a-z.
  188. Source:      isalpha.asm
  189.  
  190. Call with:   AX = keycode returned by GetKey.
  191. Returns:     if CF = 0, keycode is a character from A-Z or a-z
  192.              if CF = 1, keycode is not a character from A-Z or a-z
  193.              AX is not changed
  194. Uses:        CF
  195. Example:     call   getkey       ; get next keystroke
  196.              call   isalpha
  197.              jc     not_alpha
  198.  
  199.  
  200. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  201.  
  202. ISDIGIT:     determines if a keycode returned by GetKey is the ASCII code
  203.              for the numeric characters 0-9
  204. Source:      isdigit.asm
  205.  
  206. Call with:   AX = keycode returned by GetKey.
  207. Returns:     if CF = 0, keycode is a character from 0-9
  208.              if CF = 1, keycode is not a character from 0-9
  209.              AX is not changed
  210. Uses:        CF
  211. Example:     call   getkey       ; get next keystroke
  212.              call   isdigit      ; I want numbers only
  213.              jc     not_a_number
  214.  
  215.  
  216.  
  217. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  218.  
  219. ISLOWER:     determine if a keycode returned by GetKey is lower case
  220. Source:      islower.asm
  221.  
  222. ISUPPER:     determine if a keycode returned by GetKey is upper case
  223. Source:      isupper.asm
  224.  
  225. Call with:   AX = keycode returned by GetKey.
  226. Returns:     if CF = 0, keycode is a character from A-Z or a-z
  227.              if CF = 1, keycode is not a character from A-Z or a-z
  228.              AX is not changed
  229. Uses:        CF
  230. Example:     call   getkey       ; get next keystroke
  231.              call   isupper      ; is it upper case?
  232.              jc     not_upper    ; no; could be lower case
  233.  
  234.  
  235.  
  236. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  237.  
  238. JANEIN:      German language version of YesNo
  239.              waits for 'J' or 'N' key to be pressed
  240. Source:      janein.asm
  241.  
  242. Call with:   no parameters
  243.              Key pressed may be upper or lower case.  Upper case is
  244.              returned.  Uses BIOS functions
  245. Returns:     AX = 'J' or AX = 'N'
  246.              future version will also return ^C
  247. Uses:        AX
  248. Example:
  249.  
  250. include asm.inc
  251.  
  252. extrn   JaNein:proc
  253.  
  254. .code
  255.         .
  256.         .
  257.         .
  258.         call  JaNein
  259.  
  260.  
  261.  
  262. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  263.              
  264. KEYIFWAITING:Returns first key if one is waiting in the keyboard buffer,
  265.              or returns with no keycode if no keypress is waiting.
  266. Source:      kifwait.asm (keywait.asm, getkey.asm, kbdtype.asm)
  267.  
  268. Call with:   no parameters
  269. Returns:     AX = 0 if no key waiting
  270.              AX = keycode if one is waiting in the buffer.  Uses BIOS.
  271. Uses:        AX
  272. Supports:    standard or enhanced keyboard
  273. Example:     call  keyifwaiting
  274.  
  275.  
  276.  
  277. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  278.  
  279. KEYORBUTTON: waits for first keypress or mouse button click
  280. Source:      mouse.asm (kifway.asm, getkey.asm, kbdtype.asm)
  281.  
  282. Call with:   no parameters
  283.              If a keypress is waiting in the keyboard buffer before
  284.              this subroutine is called, the keycode is returned to
  285.              the calling program without checking mouse button status.
  286. Returns:     AX = keycode, BX = mouse button code (see MouseStatus)
  287. Uses:        AX, BX
  288. Supports:    2- or 3-button mouse, standard or enhanced keyboard
  289. Example:     call   keyorbutton
  290.  
  291.  
  292. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  293.  
  294. KEYWAITING:  Determines if a key is waiting in the keyboard buffer.
  295.              Does not remove the key code from the buffer.  Uses BIOS.
  296. Source:      keywait.asm (getkey.asm, kbdtype.asm)
  297.  
  298. Call with:   no parameters
  299. Returns:     AX = 0 if no key waiting
  300.              AX = 1 if key waiting
  301. Uses:        AX
  302. Supports:    standard or enhanced keyboard
  303. Example:     call   keywaiting
  304.              or     ax,ax        ; has a key been pressed?
  305.              jz     no_key       ; nope, not yet
  306.  
  307.  
  308. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  309.  
  310. MARKCOUNT:   determines number of filenames marked in valid MARKFILE list
  311. Source:      markcnt.asm
  312.  
  313. Call with:   ES = valid segment address of filename list returned by
  314.              MARKFILE
  315. Returns:     AX = number of filenames marked
  316. Uses:        AX, flags
  317. See also:    MARKFILE, GETMARKED
  318. Example:     see MARKFILE
  319.  
  320.  
  321.  
  322. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  323.  
  324. MARKFILE:    display a list of filenames, marking one or more for later
  325. Source:      markfile.asm ($mflist.asm, $pick.asm, others)
  326.  
  327. Call with:   DS:[SI] pointing to filespec
  328.              CX = file attributes
  329.              DH = screen row for top of list
  330.              DL = left screen column for list
  331.  
  332.              If CX bit 4 (directory attribute) is set, ALL subdirectories
  333.              of the specifed path are displayed, whether they match the
  334.              filespec or not.
  335.  
  336.              Files may be marked with the '+' key, unmarked with '-';
  337.              Esc or Enter returns control to the calling program.  Use
  338.              the Up, Down, PageUp, PageDown, Home and End keys to move
  339.              the cursor.
  340.  
  341.              If MarkFile is called with DS:[SI] pointing to a NUL byte,
  342.              it assumes that ES is the segment address of a filename
  343.              list previously created by MARKFILE and displays the list
  344.              again.
  345.  
  346. Returns:     If CF = 0:
  347.               ES = segment address of filename structure
  348.               AX = keycode pressed to exit MARKFILE
  349.               If the '+' key was pressed with the cursor positioned at
  350.               the name of a directory, AX = '+'.
  351.  
  352.              If CF = 1, AX = DOS error code
  353.  
  354. Uses:       AX, ES, CF
  355. Supports:   MENUOPTION colors and frame style
  356. See also:   MARKCOUNT, GETMARKED, MENUOPTION
  357.  
  358. Example on next page
  359.  
  360.  
  361. ; MARKFILE Example:
  362.  
  363. include asm.inc
  364.  
  365. extrn   markfile:proc, markcount:proc, getmarked:proc
  366.  
  367. .data
  368. files   db '*.asm',0        ; look for all .ASM files in current directory
  369.  
  370. .code
  371.          .
  372.          .
  373.          .
  374.         lea     si,files
  375.         mov     dx,0303h       ; 4th row, 4th column
  376.         mov     cx,10h         ; normal files + directories
  377.         call    markfile
  378.         jc      done
  379.  
  380. ; were any marked?
  381.         call    markcount
  382.         test    ax,ax          ; any marked?
  383.         jnz     several_marked
  384.         dec     ax             ; get filename at cursor
  385.         jmp     short filename_loop
  386.  
  387. several_marked:
  388.         xor     ax,ax
  389. filename_loop:
  390.         call    getmarked
  391.         jc      done
  392.         call    do_something_with_the_file
  393.         inc     ax
  394.         jmp     filename_loop
  395.  
  396. done:
  397.  
  398.  
  399. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  400.  
  401. MENUOPTION:  options for PULLDOWN, PICKF, GPICKF, PICKSTR and GPICKSTR
  402. Source:      a$menu.asm
  403.  
  404. Call with:   AX = option value
  405.              BX = option number
  406.  
  407.              If you do not specify any options or if you call MenuOption
  408.              with AX = 0, default values are assumed.
  409.  
  410.              options available are:           defaults:
  411.                0 = normal text color            07h
  412.                1 = current selection color      70h
  413.                2 = list box color               0Fh
  414.                3 = hotkey color                 0Fh         (1)
  415.                4 = optional quitkey             no quitkey  (2)
  416.                5 = exit when hotkey pressed     00h         (3)
  417.                6 = box frame type (see WFRAME)  -1          (4)
  418.  
  419. NOTE: DEFAULT COLORS MAY NOT BE SUITABLE FOR SOME GRAPHICS MODES
  420.  
  421. (1) the first upper-case letter in each string is that string's hotkey
  422.     no upper-case character = no hotkey
  423. (2) the quitkey value is a keycode returned by GetKey
  424. (3) use AX = -1 for exit when hotkey pressed, AX = 0 to disable
  425. (4) text modes only
  426.  
  427. Returns:     nothing
  428. Uses:        nothing
  429. Supports:    GPickF, GPickStr, PullDown, PickF, PickStr menu systems
  430. Example:
  431.  
  432. include   asm.inc
  433. extrn     menuoption:proc, pulldown:proc
  434.  
  435. .code
  436.           .
  437.           .
  438.           .
  439.           mov   bx,0         ; text color
  440.           mov   ax,23        ; white w/ blue background
  441.                              ; in graph modes, this would be
  442.                              ; MOV  AX,0107h  (see GCOLOR in GRAPHICS.DOC)
  443.           call  menuoption
  444.  
  445.  
  446.  
  447.  
  448. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  449.  
  450. MOUSELIMIT:  limits mouse's range of motion
  451. Source:      mouse.asm
  452.  
  453. Call with:   DS:[BX] pointing to pixel coordinates of minimum and maximum
  454.              x and y limits.  X-limits are the horizontal dimension and
  455.              y-limits are the vertical dimension.
  456. Returns:     nothing
  457. Uses:        nothing
  458. Example:
  459.  
  460. .data
  461.  
  462. x0    dw 30
  463. y0    dw 15
  464. x1    dw 620
  465. y1    dw 250
  466.  
  467. .code
  468.        .
  469.        .
  470.        .
  471.       mov    ax,@data      ; you don't need to do this stuff after
  472.       mov    ds,ax         ; your startup code unless you've messed with
  473.       assume ds:@data      ; DS somewhere earlier in the program
  474.  
  475.       lea    bx,x          ; DS:[BX] points to limits
  476.       call   mouselimit
  477.  
  478.  
  479.  
  480. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  481.  
  482. MOUSEPOS:    sets the mouse's position
  483. Source:      mouse.asm
  484.  
  485. Call with:   DS:[DX] pointing to desired x- and y-coordinates
  486.              Note that mouse coordinates are expressed as a pixel location
  487.              as with graphics mode, even if the system is in text mode
  488. Returns:     nothing
  489. Uses:        nothing
  490. Example:
  491.  
  492. .data
  493.  
  494. x     dw 100
  495. y     dw 25
  496.  
  497. .code
  498.       .
  499.       .
  500.       .
  501.       mov    ax,@data      ; you don't need to do this stuff after
  502.       mov    ds,ax         ; your startup code unless you've messed with
  503.       assume ds:@data      ; DS somewhere earlier in the program
  504.  
  505.       lea    dx,x          ; DS:[DX] points to desired position
  506.       call   mousepos
  507.  
  508.  
  509. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  510.  
  511. MOUSESTATUS: determine mouse position & buttons pressed
  512. Source:      mouse.asm
  513.  
  514. Call with:   no parameters
  515. Returns:     if ZF = 1, no buttons are pressed
  516.              if ZF = 0, BX = button code
  517.               BX bit 0 if set = left button is down
  518.               BX bit 1 if set = right button is down
  519.               BX bit 2 if set = center button is down
  520.              CX = horizontal (x) coordinate
  521.              DX = vertical (y) coordinate
  522.              Note that mouse positions are expressed as a pixel location
  523.              as with graphics mode, even if the system is in text mode
  524. Uses:        BX, CX, DX, flags
  525. Example:     call  mousestatus
  526.              jz    no_buttons     ; no buttons pressed if ZF = 1
  527.  
  528.  
  529.  
  530. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  531.  
  532. OUINON:      French language version of YesNo
  533.              waits for 'O' or 'N' key to be pressed
  534. Source:      ouinon.asm
  535.  
  536. Call with:   no parameters
  537.              Key pressed may be upper or lower case.  Upper case is
  538.              returned.  Uses BIOS functions
  539. Returns:     AX = 'O' or AX = 'N'
  540.              future version will also return ^C
  541. Uses:        AX
  542. Example:
  543.  
  544. include asm.inc
  545.  
  546. extrn   OuiNon:proc
  547.  
  548. .code
  549.         .
  550.         .
  551.         .
  552.         call  OuiNon
  553.  
  554.  
  555.  
  556.  
  557.  
  558. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  559.  
  560. PICKF:       pick a file from a list of filenames
  561.              PickF pops a window on the screen and displays filenames
  562.              matching an input filespec mask.  One filename may be selected
  563.              with cursor keys or with hotkeys.  When Esc, Enter or ^C is
  564.              pressed, PickF restores the screen and returns the selected
  565.              filename to the calling program.
  566.              Unused memory must be released by STARTUP (see STARTUP.ASM).
  567.              PickF allocates a block of DOS memory which should be released
  568.              after you are done with it.  See example.
  569.              See also MenuOption.
  570. Source:      pickf.asm ($pick.asm, m$putw.asm, filelist.asm,
  571.                           allocdos.asm, wsave.asm, a$menu.asm)
  572.  
  573. Call with:   DS:[SI] pointing to filespec mask
  574.              BX = initial cursor position
  575.              CX = file attribute mask
  576.              DH = top screen row for list (centered if DH = 0FFh)
  577.              DL = left screen column for list (centered if DL = 0FFh)
  578. Returns:     if CF = 0, AX = last key pressed
  579.                         ES:[BX] points to filename selected
  580.                         CX = maximum length of filename
  581.              if CF = 1, no filenames match input filespec
  582. Uses:        AX, BX, CX, ES, CF
  583. Supports:    text mode
  584. Example:
  585.  
  586. include   asm.inc
  587.  
  588. public    myproc
  589. extrn     pickf:proc
  590.  
  591. .data
  592. filespec db '*.asm',0            ; search for ASM source code
  593.  
  594. .code
  595. ; program fragment assumes DS:@data
  596.         .
  597.         .
  598.         .
  599.         lea     si,filespec
  600.         mov     bx,0             ; start at top of list
  601.         xor     dx,dx            ; upper left corner of screen
  602.         mov     cx,0             ; normal files only
  603.         call    pickf
  604.         cmp     ax,0Dh           ; was Enter the last key pressed?
  605.         jne     abort            ;  nope - someone wants out
  606.         call    strndup          ;  yup - copy filename to near heap
  607.         mov     ah,49h
  608.         int     21h              ; release the filename buffer
  609.  
  610.  
  611. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  612.  
  613. PICKSTR:     pick a string from a list of ASCIIZ strings
  614. Source:      pickstr.asm ($pick.asm, m$putw.asm, $strlist.asm,
  615.                           allocdos.asm, wsave.asm, a$menu.asm)
  616.  
  617. Call with:   DS:[SI] pointing to list of ASCIIZ strings
  618.              BX = initial cursor position
  619.              DH = top screen row for list (centered if DH = 0FFh)
  620.              DL = left screen column for list (centered if DL = 0FFh)
  621.  
  622.              PickStr pops a window on the screen and displays the list
  623.              of strings.  One string may be selected with cursor keys
  624.              or with hotkeys.  When Esc, Enter or ^C is pressed, PickStr
  625.              restores the screen and returns a string index number.
  626.              Unused memory must be released by STARTUP (see STARTUP.ASM).
  627.              See also MenuOption.  Maximum number of choices: 255
  628.  
  629. Returns:     AX = last key pressed
  630.              BX = string number selected (first string = 0)
  631. Uses:        AX, BX
  632. Supports:    text mode
  633. Example:
  634.  
  635. include   asm.inc
  636.  
  637. public    myproc
  638. extrn     pickstr:proc
  639.  
  640. .data
  641. string1   db 'January',0
  642.           db 'February',0
  643.           db 'March',0
  644.           db 'April',0
  645.           db 'May',0
  646.           db 'June',0
  647.           db 'July',0
  648.           db 'August',0
  649.           db 'September',0
  650.           db 'October',0
  651.           db 'November',0
  652.           db 'December',0
  653.           db 0              ; mark end of menu strings
  654.  
  655. .code
  656. ; program fragment assumes DS:@data
  657.         .
  658.         .
  659.      lea  si,string1
  660.      mov  bx,1
  661.      xor  dx,dx
  662.      call pickstr
  663.  
  664. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  665.  
  666. PULLDOWN:    pull-down menu system
  667. Source:      pulldown.asm (a$menu.asm, tprint.asm, tprintce.asm, tputchr.asm
  668.                            strlen.asm, wclear.asm, wframe.asm, wsize.asm
  669.                            wsave.asm, getkey.asm, pickstr.asm and others)
  670.  
  671. Call with:   DS:[SI] pointing to menu labels
  672.              BH = initial main menu choice, BL = initial submenu choice
  673.              assumes DS:@data
  674.              Unused memory must be released (see STARTUP.ASM and ENDPROG)
  675.  
  676.              If PullDown is called with BL < 0, only the main headings are
  677.              printed initally; the submenus are printed when ENTER is
  678.              pressed, a mouse button is pressed, or when either the down
  679.              arrow key is pressed or a "down" mouse movement is detected.
  680.  
  681.              If PullDown is called with BL >= 0, it starts in the full main
  682.              headings plus submenus mode.  In this mode, a mouse button
  683.              click or the ENTER key will exit PullDown.  In either mode,
  684.              ESC, ^C or the user-defined quitkey (see MenuOption) causes
  685.              PullDown to return to the calling program.
  686.  
  687.              If there are too many main headings to fit across the top of the
  688.              screen, the headings are scrolled left or right as required to
  689.              show the selected heading.  Use Left, Right, Home and End keys
  690.              to change selected headings.  Maximum number of headings: 20
  691.  
  692.              If there are too many submenu choices under a heading to fit
  693.              on the screen, the selections are scrolled up or down as required
  694.              to show the selected item.  Use Up, Down, PgUp, PgDown keys
  695.              to change selection, or press highlighted letter of selection.
  696.              Maximum number of selections per heading: 255
  697.  
  698. Returns:     BH = main menu choice, BL = submenu choice
  699.              if CF = 1, ^C or Ctrl-Break was pressed
  700.              if CF = 0
  701.                  AX = 13 if ENTER was pressed
  702.                  AX = user-defined quitkey if pressed (see MenuOption)
  703.                  AX = 0 if insufficient DOS memory is available
  704.                  AX = 27 if ESC was pressed
  705.                  AH = 1-7, AL = 0 if mouse button pressed
  706. Uses:        AX, BX
  707. Supports:    text mode; all row/column configurations supported by ASMLIB
  708.              Text subroutines
  709. Example:
  710.  
  711. see next page
  712.  
  713. ;    this sample menu has 4 main menu headings:
  714. ;                          Critters, Things, Food, Trees
  715. ;    submenu choices for each main heading follow each main heading
  716. ;    Note that each string is terminated with NUL, and that there's an
  717. ;    extra NUL between the end of the submenu choices and the next main
  718. ;    heading.
  719. ;    The entire set of menu choices is terminated with 2 NUL bytes
  720. ;
  721. ;    PULLDOWN will return to the calling program when either ESCAPE or
  722. ;    ENTER is pressed (AX = ASCII code of key pressed).  PULLDOWN returns
  723. ;    AX = 0 if insufficient memory is available to save the underlying
  724. ;    screen, or AX = 3 if breaktrap was enabled and Ctrl+Break was pressed.
  725. ;
  726. ;    On return, BH = the main heading and BL = the submenu choice in effect
  727. ;    when the key was pressed.  The first main heading is number 0, and
  728. ;    the first submenu choice for each main heading is also number 0.
  729.  
  730. include asm.inc
  731.  
  732. extrn     pulldown:proc
  733.  
  734. .stack
  735.  
  736. .data
  737. menu    db 'Critters',0
  738.         db 'Goats',0,'Chickens',0,'Turkeys',0,'Cows',0,'Snow dogs',0
  739.  
  740.         db 0                   ; separate Things from Critters
  741.         db 'Things',0
  742.         db 'Computers',0,'Tractors',0,'CPU chips',0,'Barbie dolls',0
  743.  
  744.         db 0                   ; separate Food from Things
  745.         db 'Food',0
  746.         db 'Hot dogs',0,'Wheat germ',0,'Lasagne',0,'Cheerios',0
  747.         db 'Potatoes',0,'chocolate chip cooKies',0
  748.  
  749.         db 0                   ; separate Trees from Food
  750.         db 'Trees',0
  751.         db 'giant Sequoia',0,'black Spruce',0,'Willow',0,'live Oak',0
  752.         db 'Acacia',0,'digger Pine',0
  753.  
  754.         db 2 dup(0)            ; end of menu choices
  755.  
  756. .code
  757. ; program fragment assumes DS:@data
  758.         .
  759.         .
  760.         .
  761.         lea   si,menu          ; point to menu labels
  762.         xor   bx,bx            ; initial selection is "goats"
  763.         call  pulldown
  764.  
  765.  
  766. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  767.  
  768. SINO:        Spanish language version of YesNo
  769.              waits for 'S' or 'N' key to be pressed
  770. Source:      sino.asm
  771.  
  772. Call with:   no parameters
  773.              Key pressed may be upper or lower case.  Upper case is
  774.              returned.  Uses BIOS functions
  775. Returns:     AX = 'S' or AX = 'N'
  776.              future version will also return ^C
  777. Uses:        AX
  778. Example:     call  sino
  779.  
  780.  
  781. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  782.  
  783. TEDIT:       ASCIIZ string editor for text modes
  784.              See also GEdit for graphics modes, A$EDIT for general information.
  785.              TEdit turns the cursor off (with CursorOFF) on exit.
  786. Source:      tedit.asm (a$edit.asm, cursor.asm, a$clrw.asm, str2vbuf.asm,
  787.                         crtinfo.asm)
  788.  
  789. Call with:   DS:[SI] pointing to string buffer; may include a default string
  790.              assumes DS:@data
  791.              CX = byte size of buffer (excluding terminating NUL)
  792.              AH = color attribute
  793.              AL = option bits (see A$EDIT)
  794.              DH = row (offset from top of screen)
  795.              DL = column (offset from left edge of screen)
  796.  
  797. Returns:     AX = last key pressed (see GetKey for key codes)
  798.              CX = new string length
  799. Uses:        AX, CX, flags
  800. Supports:    text modes; all row/column configurations
  801.  
  802. Example on next page
  803.  
  804.  
  805. ; TEdit example:
  806.  
  807. include asm.inc
  808.  
  809. extrn   tedit:proc
  810.  
  811. .data
  812. extrn   estart:word, elast:word
  813. string_buffer   db 120 dup(' ')
  814. len_buffer      equ $-string_buffer
  815.                 db 0              ; give it a terminal NUL
  816.  
  817. .code
  818. ; program fragment assumes DS:@data
  819.         .
  820.         .
  821.         .
  822. string_edit:
  823.         lea     si,string_buffer    ; near address of string buffer
  824.         mov     cx,len_buffer       ; byte length of buffer for the string
  825.         mov     dh,row
  826.         mov     dl,column
  827.         mov     ah,attr             ; color attribute
  828.         mov     al,2                ; force lower case
  829.         or      al,4                ; trap Up & Down arrow keys
  830.         call    tedit
  831.         shr     ah,1                ; returned due to extended key?
  832.         jnc     normal_exit
  833.  
  834. ; check for desired extended keys
  835.         cmp     al,72               ; Up arrow key?
  836.         je      go_up
  837.         cmp     al,80               ; Down arrow key?
  838.         je      go_down
  839.  
  840. ; extended key pressed was not Up or Down
  841. ; get cursor position when key was pressed & force TEdit to resume
  842. ; at that point
  843.         mov     ax,elast            ; last cursor position
  844.         mov     estart,ax           ; force non-zero starting offset
  845.         jmp     string_edit
  846.  
  847.  
  848.  
  849. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  850.  
  851. TMOUSELIMIT: limits mouse's range of motion on text mode screen
  852. Source:      tmlimit.asm
  853.  
  854. Call with:   DS:[BX] pointing to character coordinates of minimum and maximum
  855.              rows and columns.  Columns are the horizontal dimension and
  856.              rows are the vertical dimension.
  857. Returns:     nothing
  858. Uses:        nothing
  859. Example:
  860.  
  861. .data
  862.  
  863. x0    dw 3          ; first row
  864. y0    dw 1          ; first column
  865. x1    dw 20         ; last row
  866. y1    dw 50         ; last column
  867.  
  868. .code
  869. ; program fragment assumes DS:@DATA
  870.        .
  871.        .
  872.        .
  873.       lea    bx,x          ; DS:[BX] points to limits
  874.       call   tmouselimit
  875.  
  876. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  877.  
  878. TMOUSEPOS:   set mouse position on text-mode screen
  879. Source:      tmouspos.asm
  880.  
  881. Call with:   DH = row (vertical position)
  882.              DL = column (horizontal position)
  883. Returns:     nothing
  884. Uses:        flags
  885. Example:
  886.  
  887. ; I want to center the mouse cursor on a standard 80-column, 25-row screen
  888.  
  889. include asm.inc
  890.  
  891. extrn   tmousepos:proc
  892.  
  893. .code
  894.         .
  895.         .
  896.         .
  897.         mov    dh,12           ; close to vertical center
  898.                                ; coordinates are 0 through 24 vertially
  899.         mov    dl,39           ; coordinates are 0 through 79 horizontally
  900.         call   tmousepos
  901.  
  902.  
  903. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  904.  
  905. TMOUSESTATUS:determine mouse position on text screen & buttons pressed
  906. Source:      tmstatus.asm
  907.  
  908. Call with:   no parameters
  909.              assumes mouse is installed (see IsMouse in SYSTEM.DOC)
  910. Returns:     if ZF = 1, no buttons are pressed
  911.              if ZF = 0, BX = button code
  912.               BX bit 0 if set = left button is down
  913.               BX bit 1 if set = right button is down
  914.               BX bit 2 if set = center button is down
  915.              DH = row (vertical position)
  916.              DL = column (horizontal position)
  917. Uses:        BX, DX, flags
  918. Example:     call  tmousestatus
  919.              jz    no_buttons     ; no buttons pressed if ZF = 1
  920.  
  921.  
  922.  
  923. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  924.  
  925. TOLOWER:     converts keycode returned by getkey to lower case
  926. Source:      tolower.asm
  927.  
  928. Call with:   AX = keycode
  929. Returns:     AX = lower case keycode
  930.              ToLower leaves the keycode alone if the keycode is not
  931.              upper case A-Z.
  932. Uses:        AX
  933. Example:     call   getkey
  934.              call   tolower
  935.  
  936.  
  937. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  938.  
  939. TOUPPER:     converts keycode returned by getkey to upper case
  940. Source:      toupper.asm
  941.  
  942. Call with:   AX = keycode
  943. Returns:     AX = upper case keycode
  944.              ToUpper leaves the keycode alone if the keycode is not
  945.              lower case a-z.
  946. Uses:        AX
  947. Example:     call   getkey
  948.              call   toupper
  949.  
  950.  
  951. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  952.  
  953. YESNO:       waits for 'Y' or 'N' key to be pressed
  954. Source:      yesno.asm
  955.  
  956. Call with:   no parameters
  957.              Key pressed may be upper or lower case.  Upper case is
  958.              returned.  Uses BIOS functions
  959. Returns:     AX = 'Y' or AX = 'N'
  960.              future version will also return ^C
  961. Uses:        AX
  962. Example:     call  yesno
  963.  
  964.  
  965.